package com.cloud.wyf.Mapper;

import com.cloud.wyf.Entity.MiddelScore;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MiddelScoreMapper {
    @Insert("<script>insert into middelscore(mvoteid,mid,year) values " +
            "<foreach collection = 'list' item='record' separator=',' >" +
            "(#{record.mvoteid},#{record.mid},#{record.year})" +
            "</foreach></script>")
    int addMiddelScoreMult(List<MiddelScore> list);

    @Select("select * from middelscore where mvoteid=#{mvoteid} and mid=#{mid}")
    MiddelScore selectByMAndMId(@Param("mvoteid") String mvoteid, @Param("mid")String mid);

    @Select("select * from middelscore where mvoteid=#{mvoteid}")
    List<MiddelScore> selectMiddelScoreByMId( String mvoteid);

    @Update("<script>update middelscore set item1=#{item1},item2=#{item2},item3=#{item3},item4=#{item4}," +
            "item5=#{item5},score=#{score},submittime=now()," +
            "status=1,flag=0,year=#{year}<if test=\"description != null and description != '' \">,description=#{description}</if> " +
            "where mvoteid=#{mvoteid} and mid=#{mid}</script>")
    int updateLeaderScore(MiddelScore middelScore);

    @Update("update middelscore set submittime=now(),flag=1 where lmvoteid=#{mvoteid} and mid=#{mid}")
    int updateMiddelScoreQuit(@Param("mvoteid") String mvoteid, @Param("mid")String mid);
}
